<?php
$op = $_GET['op'];
$goods_id = intval($_GET['goods_id']);
$sql = "select id,title,taobao_id,pic_url,price,price-tuan_derate as tuan_price,tuan_end,tuan_derate,coupon_link,goods_link,num from tttj.goods where id = ".$goods_id;
$data = getonerecord($sql);
$tpl->assign('data',$data);

$stime = time()+3600;
$etime = time()-3600;

$sql = "select id from tttj.goods order by rand() limit 5";
$buy_num = getarrrecord($sql);
foreach($buy_num as $k=>$v){
    $buy_num[$k]['time'] = rand($etime,$stime);
}
$tpl->assign('buy_num',$buy_num);


if($op == 'search_goods'){
    $search_id = $_REQUEST['search_goods_id'];
    $sql = "select id,taobao_id,title,pic_url,num,coupon_link,di_type,di_cash,price,reserve_price,goods_link,remain from tttj.goods as a WHERE a.id = $search_id";
    $row = getonerecord($sql);
    $item['gtbid'] = $row['taobao_id'];
    $item['gname'] = $row['title'];
    $item['gicon'] = $row['pic_url'];
    $item['stock'] = $row['num'];
    $item['glink'] = $row['goods_link'] ? $row['goods_link'] : '';

    $item['di_type'] = $row['di_type'];
    $item['di_cash'] = $row['di_cash'];
    $item['gprice'] = $row['price'] - $row['di_cash'];
    $item['gyuan'] = $row['price'];
    $item['remain'] = $row['remain'];
    if($row['coupon_link']){
        $item['clink'] = $row['coupon_link'];
    }else{
        $item['clink'] = '';
    }
    $item['buy_type'] = 4;
    $item['goods_id'] = $row['id'];
    $appid = $_GET['appid'];
    record_goods($search_id,5,1);
    echo echojson('success',1,$item);exit;
}

$tpl->display("{$tp}.html");
?>